<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );

class Taphoto extends CI_Controller {
	
	function __construct() {
		parent::__construct ();
	
	}
	
	public function index() {
		
		$id = (int)$this->uri->segment(2);
		if(!isset($id) || $id == ''){
			$this->load->view('error');
			return ;
		}
		$member = $this->session->userdata ( 'member' );
		/*if($member != null && $member['id'] == $id){
			redirect('member/photolist');
		}*/
		//该会员的信息
		$this->db->select('*');
		$this->db->from('member');
		$this->db->where('id',$id);
		$eData['tamember'] = $this->db->get()->row_array();
		
		
		$this->db->where ( 'type', 1);
		$this->db->where ( 'belongId', $id );
		$this->db->order_by('createtime', 'DESC');
		$photoList = $this->db->get ('picture')->result_array ();
		$eData ['photoList'] = $photoList;
		
		$eData['eID'] = $id;
		$this->load->view('taphoto',$eData);
	}
	
	public function show(){
		$id = (int)$this->uri->segment(3);
		$picId = (int)$this->uri->segment(4);
		
		//该会员的信息
		$this->db->select('*');
		$this->db->from('member');
		$this->db->where('id',$id);
		$eData['tamember'] = $this->db->get()->row_array();
		
		$this->db->where ( 'id', $picId );
		$eData['photo'] = $this->db->get ('picture')->row_array();
		
		$this->db->select('max(createtime),id');
		$this->db->where('createtime < ',$eData['photo']['createtime']);
		$this->db->where('type',1);
		$this->db->where('belongId',$id);
		$eData['nextphoto'] = $this->db->get ('picture')->row_array();
		
		$this->db->select('min(createtime),id');
		$this->db->where('createtime > ',$eData['photo']['createtime']);
		$this->db->where('type',1);
		$this->db->where('belongId',$id);
		$eData['prephoto'] = $this->db->get ('picture')->row_array();
		
		$eData['eID'] = $id;
		$this->load->view('taphotoshow',$eData);
	}
	
}

